package com.fyw.xmcamera;

import android.content.Intent;
import android.os.Bundle;

import org.apache.cordova.CallbackContext;
import org.apache.cordova.CordovaPlugin;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by FYW on 2017/10/19.
 */

public class StartPlugin extends CordovaPlugin {
    private CallbackContext mCallbackContext;

    @Override
    public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
        if ("play".equals(action)) {
            Intent intent = new Intent(this.cordova.getActivity().getApplicationContext(), MainActivity.class);
            /*Bundle bundle = new Bundle();
            JSONObject jsonObject = args.getJSONObject(0);
            bundle.putString("name", jsonObject.getString("loginName"));
            intent.putExtras(bundle);*/
            this.cordova.getActivity().startActivity(intent);
            mCallbackContext.success("success");
            return true;
        }
        mCallbackContext.error("error");
        return false;
    }
}
